package com.daisuxia.payRoute;

import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URISyntaxException;
import java.util.Map;

import com.daisuxia.risk.service.IOutOrdersService;
import com.daisuxia.web.pojo.Repayment;
import com.daisuxia.web.pojo.User;
import com.daisuxia.web.pojo.UserCardInfo;

/**
 * Created by dhl on 2017/5/18.
 */
//支付路由代理
public class PayRoute {
	//支付管理者
	private static PayManager payManager ;


	public  PayRoute(IOutOrdersService outOrdersService){
		init(outOrdersService);
	}

	void init(IOutOrdersService outOrdersService) {
		payManager = new PayManager();
		//第一个支付机构 rongbao
		IPayCommons iPayCommons1 = new RongBaoPay(outOrdersService);
		//第二个支付机构 baofoo
		IPayCommons iPayCommons2 = new BaofooPay(outOrdersService);

		//注册支付机构
		payManager.registerIPay(iPayCommons1,iPayCommons2);
	}
	/**
	 * 获取代扣信息
	 * @param re 借款信息
	 * @param user 用户
	 * @param userCardInfo 卡号
	 * @param transId 订单号
	 * @return
	 * @throws IOException
	 * @throws URISyntaxException
	 */
	public Map getCutPay(Repayment re, User user, UserCardInfo userCardInfo, String transId) throws IOException, URISyntaxException {

		return payManager.handleOrder(re,user,userCardInfo,transId);
	}

}
